﻿using System.Web.UI;

namespace AutoCompleteTextBox
{
    public static class ControlHelper
    {
        public const string DefaultYUIPath = @"http://yui.yahooapis.com/3.5.0/build/yui/yui-min.js";
    
        internal static Control FindControl(Control control, string controlID)
        {
            Control namingContainer = control;
            Control needfulControl = null;
            if (control != control.Page)
            {
                while ((needfulControl == null) && (namingContainer != control.Page))
                {
                    namingContainer = namingContainer.NamingContainer;

                    needfulControl = namingContainer.FindControl(controlID);
                }
                return needfulControl;
            }
            return control.FindControl(controlID);
        }
    }
}
